package com.talent.study.hello;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

import java.util.HashMap;

/**
 * @Author: hszhou
 * @Date: 2025/6/5 16:27
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public class StatusConverter  implements Converter<Integer> {


    private static HashMap<String,String> map = new HashMap<>();

    static {
        map.put("0","有效 Valid");
        map.put("1","已注销 Cancelled\"");
        map.put("2","已撤销 Withdrawn");
        map.put("3","已暂停 Suspended");
        map.put("6","已过期 Expired");
    }
    @Override
    public Class supportJavaTypeKey() {return Integer.class;}

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {return CellDataTypeEnum.STRING;}

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String s = map.get(value.toString());
        return new WriteCellData<>(s);
    }
    //将excel的数据类型转为java数据类型

}